package com.qfxl.common.util;

/**
 * @Title: DataMap
 * @Author cj
 * @Package org.sckj.yeby.util
 * @Date 2025/2/20 11:53
 * @description:
 */

import org.apache.commons.lang3.StringUtils;

import java.util.*;

/**
 * @author cj
 * @version 1.0
 * @description: TODO
 * @date 2025/2/20 11:53
 */
public class DataMap {

    public static Map<String, List<String>> map = new HashMap<>(100);

    public static List<List<String>> list = new ArrayList<>();
    public static Map<String, List<String>> questionMap = new HashMap<>(100);

    public static List<List<String>> questionList = new ArrayList<>();

    public static void main(String[] args) {
        String value = getValue(questionMap, questionList, "单选题", 0);
        String value1 = getValue(questionMap, questionList, "单选题", 1);
        String value2 = getValue(questionMap, questionList, "单选题", 2);
        System.out.println(value);
        System.out.println(value1);
        System.out.println(value2);
    }

    static {
        //描述、字段名称、类型字段
        setList(questionMap,questionList,"单选题","single","1");
        setList(questionMap,questionList,"多选题","multiple","2");
        setList(questionMap,questionList,"名词解释","term_definition","4");
        setList(questionMap,questionList,"不定向选择","open_choice","6");
        setList(questionMap,questionList,"判断","judgment","3");
        setList(questionMap,questionList,"导游词写作","guide_wording","c");
        setList(questionMap,questionList,"找错并改错","error_correction","7");
        setList(questionMap,questionList,"综合题","comprehensive_question","b");
        setList(questionMap,questionList,"方案设计","scheme_design","a");
        setList(questionMap,questionList,"材料分析","material_analysis","9");
        setList(questionMap,questionList,"简述题","brief_question","8");
        setList(questionMap,questionList,"简答题","short_answer","5");
    }

    public static void setList(Map<String, List<String>> map, List<List<String>> list, String... strings) {
        String key = StringUtils.join(strings, ",");
        List<String> valueList = new ArrayList<>(Arrays.asList(strings));
        map.put(key, valueList);
        list.add(valueList);
    }

    public static List<String> getValues(Map<String, List<String>> map, List<List<String>> list, String key, int index) {
        List<String> restList;
        String mapKey = "";
        for (String valueKey : map.keySet()) {
            if (valueKey.contains(key)) {
                mapKey = valueKey;
                break;
            }
        }
        List<String> strings = map.get(mapKey);
        int size = strings.size();
        if (index >= size) {
            return Arrays.asList("");
        } else {
            restList = strings;
        }

        return restList;
    }

    public static String getValue(Map<String, List<String>> map, List<List<String>> list, String key, int index) {
        List<String> values = getValues(map, list, key, index);
        int size = values.size();
        if (index >= size) {
            return "";
        } else {
            return values.get(index);
        }

    }


}
